package com.ruoyi.manager.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manager.domain.TbeduInterview;
import com.ruoyi.manager.service.ITbeduInterviewService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生采访Controller
 * 
 * @author 罗
 * @date 2021-09-17
 */
@Controller
@RequestMapping("/manager/interview")
public class TbeduInterviewController extends BaseController
{
    private String prefix = "manager/interview";

    @Autowired
    private ITbeduInterviewService tbeduInterviewService;

    @RequiresPermissions("manager:interview:view")
    @GetMapping()
    public String interview()
    {
        return prefix + "/interview";
    }

    /**
     * 查询学生采访列表
     */
    @RequiresPermissions("manager:interview:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TbeduInterview tbeduInterview)
    {
        startPage();
        List<TbeduInterview> list = tbeduInterviewService.selectTbeduInterviewList(tbeduInterview);
        return getDataTable(list);
    }

    /**
     * 导出学生采访列表
     */
    @RequiresPermissions("manager:interview:export")
    @Log(title = "学生采访", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TbeduInterview tbeduInterview)
    {
        List<TbeduInterview> list = tbeduInterviewService.selectTbeduInterviewList(tbeduInterview);
        ExcelUtil<TbeduInterview> util = new ExcelUtil<TbeduInterview>(TbeduInterview.class);
        return util.exportExcel(list, "学生采访数据");
    }

    /**
     * 新增学生采访
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存学生采访
     */
    @RequiresPermissions("manager:interview:add")
    @Log(title = "学生采访", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TbeduInterview tbeduInterview)
    {
        return toAjax(tbeduInterviewService.insertTbeduInterview(tbeduInterview));
    }

    /**
     * 修改学生采访
     */
    @GetMapping("/edit/{fId}")
    public String edit(@PathVariable("fId") Long fId, ModelMap mmap)
    {
        TbeduInterview tbeduInterview = tbeduInterviewService.selectTbeduInterviewByFId(fId);
        mmap.put("tbeduInterview", tbeduInterview);
        return prefix + "/edit";
    }

    /**
     * 修改保存学生采访
     */
    @RequiresPermissions("manager:interview:edit")
    @Log(title = "学生采访", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TbeduInterview tbeduInterview)
    {
        return toAjax(tbeduInterviewService.updateTbeduInterview(tbeduInterview));
    }

    /**
     * 删除学生采访
     */
    @RequiresPermissions("manager:interview:remove")
    @Log(title = "学生采访", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tbeduInterviewService.deleteTbeduInterviewByFIds(ids));
    }
}
